<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<div class="project_contents">
	<h1>Calendar</h1>
	<div class="project_in">
	<ul class="token_project" id="calendar_margin">	
		<li><img src="resources/images/work_title.jpg"/>업무시작일</li>
		<li><img src="resources/images/work_title_end.jpg"/>업무종료일</li>
	</ul>
	<div class="btn_margin">
		<input type="button" class="btn" style="float:left;" onclick="get_calendar(${calendar.currentYear}, ${calendar.currentMonth - 1})"value="이전" /> 
		<div id="schedule_date">${calendar.currentYear } 년/ ${calendar.currentMonth +	1 } 월</div>
		<input type="button" class="btn" onclick="get_calendar(${calendar.currentYear}, ${calendar.currentMonth + 1})"value="이후" />
	</div>
		<table id="calendar_table">
		<tr>
			<c:forEach items="${calendar.dayNames }" var="dayName">
				<th>${dayName}</th>
			</c:forEach>
		</tr>
		<tr>
			<c:forEach begin="1" end="${calendar.firstDay - 1}">
				<td><span id="day"></span></td>
				<c:set var="col" value="${col + 1 }"></c:set>
			</c:forEach>
			<c:forEach begin="1" end="${calendar.lastDay }" var="day">
			<td>
				<c:choose>
					<c:when test="${col == 0 }">
						<span id="sunday">${day }</span> 
					</c:when>
					<c:when test="${col == 6}">
						<span id="satday">${day }</span>
					</c:when>
					<c:when test="${day == calendar.currentDay }">
						<span id="today">${day } Today!</span>
					</c:when>
					<c:otherwise>
						<span id="day">${day }</span>
					</c:otherwise>
				</c:choose>
				<c:forEach var="work" items="${workList }">
								<c:if test="${work.workStartTime.getMonth() + 1
							== (calendar.currentMonth + 1) && work.workStartTime.getDate() == day}">
									<div id="work_title" title="상태 : ${work.workState} / 담당자 : ${work.name}" class="schedule_hover" onclick="pick_work(${work.workNo})">${work.workTitle
										}</div>
									<br>
								</c:if>
				</c:forEach>
				<c:forEach var="work" items="${workList }">
								<c:if test="${work.workDeadTime.getMonth() + 1
							== (calendar.currentMonth + 1) && work.workDeadTime.getDate() == day}">
									<div id="work_title_end" title="업무일정 / 상태 : ${work.workState} / 담당자 : ${work.name}" onclick="pick_work(${work.workNo})">${work.workTitle
										}</div>
									<br>
								</c:if>
				</c:forEach>
				</td>
				<c:set var="col" value="${col + 1 }" />
				<c:if test="${col == 7 }">
					<c:set var="col" value="0" />
		</tr>
		<tr>
			</c:if>
			</c:forEach>

			<c:forEach begin="${col }" end="6">
				<td></td>
				<c:if test="${col == 5}">
		</tr>
		</c:if>
		</c:forEach>

	</table>
	
	</div>
	<script>
	$(document).ready(function(){
		$('span#work_title').tooltip({position:{my:"left+30 center",at:"right top"},
			hide: {effect:"fadeOut", duration:200},
			show: {effect:"fadeIn", duration:200}
			
		});
	});
	</script>
</div>
